<?php

namespace App\Models;

use App\Helpers\commonFuc;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class AdminAuthRule extends Model
{
    protected $table = 'admin_auth_rule';

    /**获取权限菜单
     * @return array
     */
    static function getMeun($rules=null,$ismenu=null){
        $lists=self::orderByDesc('order')
            ->orderBy('pid');
        if($rules){
            $rules = is_array($rules) ? $rules : explode(',', $rules);
            $lists->whereIn('id', $rules);
        }
        if($ismenu){
            $lists->where('ismenu', 1);
        }
        $lists = $lists->get()->toArray();
        return commonFuc::menusDb_to_children_menus($lists);

    }





}
